#!/bin/bash
if [ -n "$1" ] ; then
  data_str=$1
else
  data_str=`date -d "-1 days" +%F`
fi

HDFS_TO_ODS_EVENT_APP_LOG="
LOAD DATA INPATH '/warehouse/app_logs/${data_str}' INTO TABLE jtp_app_ods.ods_event_app_log PARTITION (dt='${data_str}');
"

HDFS_TO_ODS_MD_AREAS="
LOAD DATA INPATH '/warehouse/app_basic/t_md_areas/${data_str}' INTO TABLE jtp_app_ods.ods_md_areas PARTITION (dt='${data_str}');
"

/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${HDFS_TO_ODS_EVENT_APP_LOG}"
/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e "${HDFS_TO_ODS_MD_AREAS}"